package com.example.ssss;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.NonNull;

public class ContactEditDialog extends Dialog {
    private TextView textName;
    private TextView textTel;
    private TextView textRelation;
    private TextView contactSaveBtn;
    private onPhoneOnclickListener onPhoneOnclickListener;
    private onPictureOnclickListener onPictureOnclickListener;
    private onCancelOnclickListener onCancelOnclickListener;
    public ContactEditDialog(@NonNull Context context) {
        super(context, R.style.Contact_Dialog_Msg);
    }

    public void setOnPictureOnclickListener(ContactEditDialog.onPictureOnclickListener onPictureOnclickListener) {
        this.onPictureOnclickListener = onPictureOnclickListener;
    }

    public void setOnPhoneOnclickListener(ContactEditDialog.onPhoneOnclickListener onPhoneOnclickListener) {
        this.onPhoneOnclickListener = onPhoneOnclickListener;
    }

    public void setOnCancelOnclickListener(ContactEditDialog.onCancelOnclickListener onCancelOnclickListener) {
        this.onCancelOnclickListener = onCancelOnclickListener;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.contact_dialog);
        //按空白处不能取消动画
        setCanceledOnTouchOutside(false);
        //初始化界面控件
        initView();
        //初始化界面数据
        initData();
        //初始化界面控件的事件
        initEvent();
    }

    private void initEvent() {
        contactSaveBtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //TODO save contact data

                dismiss();
            }
        });
    }

    private void initData() {

    }

    private void initView() {
        textName = findViewById(R.id.contactEditName);
        textTel = findViewById(R.id.contactEditTel);
        textRelation = findViewById(R.id.contactEditRelationship);
        contactSaveBtn = findViewById(R.id.contactSaveBtn);
    }

    public interface onPhoneOnclickListener {
        void onPhoneClick();
    }

    public interface onPictureOnclickListener {
        void onPictureClick();
    }

    public interface onCancelOnclickListener {
        void onCancelClick();
    }

    @Override
    public void show() {
        super.show();
    }
}


